diff options
| author | Fuwn <[email protected]> | 2024-02-04 21:12:49 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-04 21:12:49 -0800 |
| commit | 6b54894503af2e1ae1a7ecdd9a6c0934586ce355 (patch) | |
| tree | 1fe2e8bacfa5c95139e95fa7932edaee8ab5841a /src/routes/user/[user] | |
| parent | feat(badges): import mode (diff) | |
| download | due.moe-6b54894503af2e1ae1a7ecdd9a6c0934586ce355.tar.xz due.moe-6b54894503af2e1ae1a7ecdd9a6c0934586ce355.zip | |
fix(badges): batch import single identity
Diffstat (limited to 'src/routes/user/[user]')
| -rw-r--r-- | src/routes/user/[user]/badges/+page.svelte | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte index 523f9030..96c12e5a 100644 --- a/src/routes/user/[user]/badges/+page.svelte +++ b/src/routes/user/[user]/badges/+page.svelte @@ -377,15 +377,26 @@ }; const importBadges = () => - importImages?.forEach((image) => { - badgesPromise = fetch( - `/api/badges?image=${encodeURIComponent(image.image)}&post=${encodeURIComponent( - image.link || '#' - )}${importCategory.length > 0 ? `&category=${encodeURIComponent(importCategory)}` : ''}`, - { - method: 'PUT' - } - ); + fetch( + `/api/badges?import=true + ${importCategory.length > 0 ? `&category=${encodeURIComponent(importCategory)}` : ''} + `, + { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify( + importImages?.map((image) => ({ + image: image.image, + post: image.link || '#', + category: importCategory + })) + ) + } + ).then(() => { + importMode = false; + importImages = undefined; }); </script> @@ -723,6 +734,11 @@ <button on:click={() => importBadges()} class="button-lined no-shadow"> {$locale().user.badges.importMode.import} </button> + + <SettingHint lineBreak> + Please wait until import mode automatically disables after importing, otherwise you risk + skipping or duplicating badges. + </SettingHint> {/if} </div> </div> |